package com.wang.learn.cloudiot.service.impl;

import com.wang.learn.cloudiot.mapper.PileMapper;
import com.wang.learn.cloudiot.model.po.Pile;
import com.wang.learn.cloudiot.service.PileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author Chen Nan
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class PileServiceImpl implements PileService {

    private final PileMapper mapper;

    @Override
    public int insertPile(Pile pile) {
        pile.setTimestamp(System.currentTimeMillis());
        return mapper.insertPile(pile);
    }

    @Override
    public List<Pile> list(Pile pile) {
        return mapper.list(pile);
    }

    @Override
    public Integer deleteAll(Date date) {
        return mapper.deleteAll(new Date());
    }

    @Override
    public Integer update(Pile pile) {
        return mapper.updatePile(pile);
    }
}
